﻿;(function($) {
    $.fn.pulse = function(options) {
        // Merge passed options with defaults
        var opts = $.extend({}, $.fn.pulse.defaults, options);
        return this.each(function() {
            doPulse($(this), opts);
        });
    };

    // private method in plugin
    function doPulse($obj, opts) {
        for(var i = 0; i < opts.pulses; i++) {
            $obj.fadeTo(opts.speed,opts.fadeLow).fadeTo(opts.speed,opts.fadeHigh);
        }

        // Reset to normal
        $obj.fadeTo(opts.speed,1);
    }

    // Pulse plugin default options
    $.fn.pulse.defaults = {
        speed: "slow",
        pulses: 2,
        fadeLow: 0.2,
        fadeHigh: 1
    };
})(jQuery);

